package com.kwq.designPattern.generate.singleton;

/**
 * @author kangwanqiang
 * @date 2021/2/2
 * @description 懒汉式单例模式：什么时候用什么时候加载单例
 *              缺点：多线程并发可能破坏单例模式
 */
public class LazySingleton {
    private LazySingleton() {
    };

    private static LazySingleton singleton = null;

    public static LazySingleton getInstance() {
        if (singleton == null) {
            singleton = new LazySingleton();
        }
        return singleton;
    }
}
